#include <animation/TransformKeyFrame.h>
#include <animation/AnimationTrack.h>

namespace ne
{
    TransformKeyFrame::TransformKeyFrame(const AnimationTrack *parent, const real time)
        : KeyFrame(parent, time),
          mTranslate(Vector3::ZERO),
          mRotate(Quaternion::IDENTITY),
          mScale(Vector3::ONE)
    {
    }

    void TransformKeyFrame::setTranslate(const Vector3 &v)
    {
        mTranslate = v;
        if (mpParentTrack)
        {
            mpParentTrack->_keyFrameDataChanged();
        }
    }

    const Vector3& TransformKeyFrame::getTranslate() const
    {
        return mTranslate;
    }

    void TransformKeyFrame::setRotate(const Quaternion &q)
    {
        mRotate = q;
        if (mpParentTrack)
        {
            mpParentTrack->_keyFrameDataChanged();
        }
    }

    const Quaternion& TransformKeyFrame::getRotate() const
    {
        return mRotate;
    }

    void TransformKeyFrame::setScale(const Vector3 &v)
    {
        mScale = v;
        if (mpParentTrack)
        {
            mpParentTrack->_keyFrameDataChanged();
        }
    }

    const Vector3& TransformKeyFrame::getScale() const
    {
        return mScale;
    }

    KeyFrame* TransformKeyFrame::clone(const AnimationTrack *newParent) const
    {
        TransformKeyFrame *newKeyFrame = new TransformKeyFrame(newParent, mTime);
        newKeyFrame->mTranslate = mTranslate;
        newKeyFrame->mRotate = mRotate;
        newKeyFrame->mScale = mScale;
        return newKeyFrame;
    }

    TransformKeyFrame::~TransformKeyFrame()
    {
    }
}
